#ifndef IMAGE_H
#define IMAGE_H

#include "src/scene/scene.h"
#include <QTextStream>
#include <QImage>

#if USE_CONSOLE
class Image : public QObject{
#else


#include <QtGui>

class Image : public QWidget{
#endif //USE_CONSOLE
	Q_OBJECT

	public:
        #if USE_CONSOLE
		Image(Scene * = NULL, QImage * = NULL);
        #else
		Image(QWidget *_parent = NULL, Scene * = NULL, QImage * = NULL);
        #endif //USE_CONSOLE
		~Image();

        #if !USE_CONSOLE
        void normalSize();
        void zoomIn();
        void zoomOut();
        void fitToWindow();

        void setAreaSize(int = 400, int = 300);

        QImage *getImage();
        void setImage(QImage *);
        void setScene(Scene *_s){scene = _s;};

        void update(QImage *_img = NULL);
        #endif //!USE_CONSOLE

        void save(QString);

    private slots:
        #if USE_CONSOLE
        void updateImageLine(unsigned int, uchar *);
        #else
        void changeZoom(double);
        void saveImage();
        #endif //USE_CONSOLE

    private:
        QImage *image;
        Scene *scene;
        #if !USE_CONSOLE
        QGraphicsView *graphicView;
        double zoom;
        QDoubleSpinBox *zoomDoubleSpinBox;
        #endif //!USE_CONSOLE

        void writeMaterial(QTextStream *, Object *, const QString &);
        void writePrimitive(QTextStream *, Object *, const QString &, bool = false);
        void writeCombinedObject(QTextStream *, Object *, const QString &, bool = false);
        void writeLight(QTextStream *, Light *);
        void writeCamera(QTextStream *, Camera *);
};

#endif

